package com.sskj.b70.p.activity;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.b70.MyAppLication;
import com.sskj.b70.common.Constants;
import com.sskj.b70.m.HttpConfig;
import com.sskj.b70.m.bean.HttpData;
import com.sskj.b70.m.http.JsonCallBack;
import com.sskj.b70.p.base.BasePresenter;
import com.sskj.b70.utils.SPUtils;
import com.sskj.b70.utils.ToastUtil;
import com.sskj.b70.v.activity.PayPwdSettingActivity;

/**
 * Created by Administrator on 2018/4/3 0003.
 */

public class SettingPresenter extends BasePresenter {

    /**
     * 请求交易密码验证码
     */
    public void requestSms() {
        String mobile = MyAppLication.getMobile();
        httpService.getTradeSms(mobile)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void _onSuccess(Response<HttpData> response) {
                        HttpData body = response.body();
                        ToastUtil.showShort(body.msg);
                        if (body.status == HttpConfig.STATUS_OK) {
                            ((PayPwdSettingActivity) mView).onSmsResponseSuccess();
                        }
                    }
                });
    }

    /**
     * 设置交易密码
     *
     * @param
     */
    public void setPayPwd(String id, String tradePwd, String code) {
        httpService.setTradePwd(id, tradePwd, code)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void _onSuccess(Response<HttpData> response) {
                        HttpData httpListData = response.body();
                        ToastUtil.showShort(httpListData.getMsg());
                        if (httpListData.getStatus() == HttpConfig.STATUS_OK) {
                            ((PayPwdSettingActivity) mView).onPayPwdSettingSuccess();
                        }
                    }
                });
    }

//    public void checkCode(String code) {
//        OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.CHECK_CODE)
//                .params("mobile", MyAppLication.getMobile())
//                .params("code", code)
//                .execute(new JsonCallBack<HttpData>(this) {
//                    @Override
//                    public void _onSuccess(Response<HttpData> response) {
//                        HttpData httpListData = response.body();
//                        ToastUtil.showShort(httpListData.getMsg());
//                        if (httpListData.getStatus() ==HttpConfig.STATUS_OK) {
////                            ((PayPwdSettingActivity) mView).changeBt(code);
//                        }
//                    }
//                });
//    }
}
